package com.zhonghui.modlules.user.controller;

import com.zhonghui.common.bean.LocalUser;
import com.zhonghui.common.eshopEnum.BillDetailEnum;
import com.zhonghui.common.eshopUtil.ApiResult;
import com.zhonghui.modlules.user.eshopService.UserBillService;
import com.zhonghui.modlules.user.eshopVo.UserBillQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(value = "用户分销", tags = "用户:用户分销", description = "用户分销")
public class UserBillController {

    private final UserBillService userBillService;

    @ApiOperation(value = "积分记录",notes = "积分记录")
    @GetMapping("/integral/list")
    public ApiResult<List<UserBillQueryVo>> integral(@RequestParam(value = "page",defaultValue = "1")int page,
                                                     @RequestParam(value = "limit",defaultValue = "10")int limit){
        Long uid = LocalUser.getUser().getUid();
        return ApiResult.ok(userBillService.userBillList(uid, BillDetailEnum.CATEGORY_2.getValue(),page,limit));
    }
}
